package pta.test10.常见异常;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] arr = new int[5];
        Scanner sc = new Scanner(System.in);
        while (true){
            String choice = sc.next();
            try{
                if ("arr".equals(choice)) {
                    int index = sc.nextInt();
                    int num = arr[index];
                } else if("null".equals(choice)){
                    throw new NullPointerException();
                }else if("cast".equals(choice)) {
                    Object obj = new String("dsf");
                    Integer num = (Integer)obj;
                }else if("num".equals(choice)){
                    String str = sc.next();
                    Integer num = Integer.parseInt(str);
                }else{
                    break;
                }
            }catch (Exception e){
                System.out.println(e);
            }
        }
    }
}

